package com.ruoyi.common.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * 密码工具类
 */
public class PasswordUtils {
    
    // 123456的BCrypt加密结果
    public static final String ENCODED_PASSWORD = "$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2";
    
    public static void main(String[] args) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        String rawPassword = "123456";
        String encodedPassword = encoder.encode(rawPassword);
        
        System.out.println("原始密码: " + rawPassword);
        System.out.println("加密后的密码: " + encodedPassword);
        System.out.println("预生成的加密密码: " + ENCODED_PASSWORD);
        
        // 验证密码
        boolean matches = encoder.matches(rawPassword, encodedPassword);
        System.out.println("新生成密码验证结果: " + matches);
        
        boolean matchesPreGenerated = encoder.matches(rawPassword, ENCODED_PASSWORD);
        System.out.println("预生成密码验证结果: " + matchesPreGenerated);
    }
} 